<template>
	<view class="pageview">
		<cl-navbar  leftIconSize="40rpx" placeholder  :autoBack="false" leftIcon="">
		</cl-navbar>

		<view class="pageContent">
			<view class="centerTop">
				<view class="centerTop__view"  @click="goPage('my_setting_info')">
					<view class="centerTop__view__topview">
						<cl-avatar
							:src="user_info.avatar_url"
							size="140rpx" preview></cl-avatar>
						<view class="centerTop__view__topview__info">
							<view style="display: flex;align-items: center;">
								<text class="centerTop__view__topview__info__nickname">Hi“ {{user_info.nick_name}}</text>
								<text v-if="user_info.user_type && user_info.user_type > 0 && user_info.user_type != 6 && user_info.user_type != 8" class="typetag" style="background-color: #02D478;">{{$t('common.friend.authority')}}</text>
							</view>
							<view style="display: flex;align-items: center;margin-top: 10rpx;" @click.stop="copy">
								<text class="centerTop__view__topview__info__account">{{$t('my.index.account')}}：{{user_info.user_no}}</text>
								<u-icon name="file-text" size="15px"></u-icon>
							</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#ffffff" size="20px" style="margin-right: 20rpx;"></u-icon>
				</view>
				<view class="centerTop__signature u-line-3">
					{{$t("addressbook.friend_details.signature")}}：<span style="color: #ffffff;">{{user_info.sign_remark || $t("my.index.noSignature")}}</span> 
				</view>
			</view>
			<view class="cellviewGrop" @click="goPage('purse')">
				<view class="cellview">
					<view class="cellview__left">
						<image class="cellview__left__img" src="/static/icon/qianbao2.svg" mode=""></image>
						<text class="cellview__left__title">{{ $t('my.index.purse') }}</text>
					</view>
					<u-icon name="arrow-right" :customStyle="iconstyle"></u-icon>
				</view>
			</view>
			<view class="cellviewGrop" v-for="(setting, settingIndex) in settingList" :key="settingIndex" @click="goPage(setting.url)">
				<view class="cellview">
					<view class="cellview__left">
						<image class="cellview__left__img" :src="setting.icon" mode=""></image>
						<text class="cellview__left__title">{{ setting.name }}</text>
					</view>
					<u-icon name="arrow-right" :customStyle="iconstyle"></u-icon>
				</view>
			</view>
		</view>

		<cl-tabbar :currentTab="3"></cl-tabbar>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				iconstyle: {
					'background-image': 'linear-gradient(180deg, rgba(255, 255, 255, 1) 0, rgba(182, 139, 77, 1) 100%)',
					'color': 'rgba(255, 255, 255, 1)',
					'-webkit-background-clip': 'text',
					'-webkit-text-fill-color': 'transparent'
				},
				settingList: [{
						icon: '/static/icon/shoucang.svg',
						url: 'collect',
						name: this.$t('my.index.collect')
					},
					// {
					// 	icon: '/static/icon/heimingdan.svg',
					// 	url: 'friend_black',
					// 	name: this.$t('addressbook.friend_black.title')
					// },
					{
						icon: '/static/icon/yinsianquan.svg',
						url: 'privacy_security',
						name: this.$t('my.index.privacySecurity')
					},
					{
						icon: '/static/icon/xiaoxitongzhi.svg',
						url: 'my_setting_notification',
						name: this.$t('my.index.notification')
					},
					{
						icon: '/static/icon/shezhi.svg',
						url: 'my_setting',
						name: this.$t('my.index.setting')
					}
				]
			};
		},
		computed: {
			...mapState({
				user_info: state => state.user.user_info,
			})
		},
		async onLoad() {
			uni.hideTabBar()
			this.getinfo()
		},
		methods: {
			async getinfo(){
				try{
					let apires = await this.$api.user.info()
					if(apires){
						//更新用户信息
						this.$store.dispatch('uploadUserInfo', apires.data)
					}
				}catch(e){
					//TODO handle the exception
				}
				
			},
			copy(){
				uni.setClipboardData({
					data: this.user_info.user_no,
					showToast:false,
					success: () => {
						uni.showToast({
							icon:'none',
							title:this.$t("tost.title.copyOk")
						})
					}
				});
			},
			goPage(urlname){
				this.$Router.push({
					name:urlname
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	.typetag{
		
		white-space: nowrap;
		font-size: 20rpx;
		color: #FFFFFF;
		padding: 0 10rpx;
		height: 28rpx;
		margin-left: 10rpx;
		line-height: 28rpx;
		text-align: center;
		border-radius: 10rpx;
		background-color: #FF7676;
	}
	.centerTop {
		padding: 30rpx 30rpx 40rpx;
		padding-top: 0rpx;
		position: relative;
		box-sizing: border-box;
		&__view{
			display: flex;
			align-items: center;
			justify-content: space-between;
			&__topview {
				display: flex;
				align-items: center;
				&__info {
					display: flex;
					flex-direction: column;
					margin-left: 30rpx;
			
					&__nickname {
						font-size: 32rpx;
						color: #FFFFFF;
					}
			
					&__account {
						font-size: 24rpx;
						color: #61626E;
					}
				}
			}
		}
		
		&__signature {
			margin-top: 40rpx;
			font-size: 28rpx;
			color: #61626E;
		}
	}

	.cellviewGrop {
		background: #1E1F30;
		border-radius: 20rpx;
		margin: 0 30rpx 20rpx;

		.cellview {
			display: flex;
			justify-content: space-between;
			padding: 0 35rpx;
			height: 110rpx;

			&__left {
				display: flex;
				align-items: center;

				&__img {
					width: 40rpx;
					height: 40rpx;
				}

				&__title {
					font-size: 28rpx;
					margin-left: 20rpx;
					background-image: linear-gradient(180deg,
							rgba(255, 255, 255, 1) 0,
							rgba(182, 139, 77, 1) 100%);
					color: rgba(255, 255, 255, 1);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
				}
			}
		}
	}
</style>